// import jsonp from '../common/js/jsonp'
// import {commonParams, options} from './config'
//
// export function getSingerList () {
//   const url = ' https://u.y.qq.com/cgi-bin/musicu.fcg'
//   const data = Object.assign({}, commonParams, {
//     '-': 'getUCGI7050180917054689',
//     g_tk: '5381',
//     loginUin: 0,
//     hostUin: 0,
//     format: 'json',
//     inCharset: 'utf8',
//     outCharset: 'utf-8',
//     notice: 0,
//     platform: 'yqq.json',
//     needNewCode: 0,
//     data: {
//       'comm': {'ct': 24, 'cv': 0},
//       'singerList': {
//         'module': 'Music.SingerListServer',
//         'method': 'get_singer_list',
//         'param': {'area': -100, 'sex': -100, 'genre': -100, 'index': -100, 'sin': 0, 'cur_page': 1}
//       }
//     }
//   })
//   return jsonp(url, data, options)
// }
import axios from 'axios'

export function getSingerList (callback) {
  axios('/api/cgi-bin/musicu.fcg', {
    params: {
      '-': 'getUCGI8122611052195541',
      g_tk: 5381,
      loginUin: 0,
      hostUin: 0,
      format: 'json',
      inCharset: 'utf8',
      outCharset: 'utf-8',
      notice: 0,
      platform: 'yqq.json',
      needNewCode: 0,
      data: {
        'comm': {'ct': 24, 'cv': 0},
        'singerList': {
          'module': 'Music.SingerListServer',
          'method': 'get_singer_list',
          'param': {'area': -100, 'sex': -100, 'genre': -100, 'index': -100, 'sin': 0, 'cur_page': 1}
        }
      }
    }
  }).then(response => {
    callback(response)
  }).catch(error => {
    callback(error)
  })
}

export function getSingerDetail (singermid, callback) {
  axios('/api/cgi-bin/musicu.fcg', {
    params: {
      '-': 'getUCGI1565348995976099',
      g_tk: 5381,
      loginUin: 0,
      hostUin: 0,
      format: 'json',
      inCharset: 'utf8',
      outCharset: 'utf-8',
      notice: 0,
      platform: 'yqq.json',
      needNewCode: 0,
      data: {
        'comm': {'ct': 24, 'cv': 0},
        'singer': {
          'method': 'get_singer_detail_info',
          'param': {'sort': 5, 'singermid': singermid, 'sin': 0, 'num': 20},
          'module': 'music.web_singer_info_svr'
        }
      }
    }
  }).then(response => {
    callback(response)
  }).catch(error => {
    callback(error)
  })
}